<?php
class klausurenfragen_model extends CI_Model {

	public function __construct()
	{
		$this->load->database();
	}
	
	/*
	public function get_klausurenfragen()
	{
		$query = $this->db->get('klausurfragen');
		return $query->result_array();		
	}
	 * 
	 */
	
	public function get_klausurenfragen($klausurenid)
	{
   		$this -> db -> from('klausurfragen');
		$this -> db -> where('KlausurenID', $klausurenid);
		
		$query = $this -> db -> get();
		
		return $query->result_array();
	}
	
	public function set_klausurenfragen($klausurfragen)
	{
		$this->load->helper('url');
		foreach($klausurfragen as $frage)
		{
			if ($frage != '')
			{
				$data = array(
					'KlausurenID' => $this->input->post('klausurenid'),
					'FragenID' => $frage
				);
				$this->db->insert('klausurfragen', $data);
			}
		}
		return true; 
		#$this->db->insert('klausurfragen', $data);
	}
	/*
	public function validate_klausurfragen($klausurfragenid)
	{
		$this->load->helper('url');
		
		$ID = url_title($this->input->post('Beschreibung'), 'dash', TRUE);
		
		$data = array(
			'Beschreibung' => $this->input->post('Beschreibung'),
			'Fach' => $this->input->post('Fach'),
			'AnzahlFragen' => $this->input->post('AnzahlFragen')
		);

		$where = array('ID' => $klausurfragenid);
		return  $this->db->update('klausurfragen',$data,$where);
	}
	*/
	public function delete_klausurenfragen()
	{
		$this->load->helper('url');

		$klausurenid = $this->input->post('klausurenid');
		$this -> db -> where('KlausurenID', $klausurenid);
		return $this -> db -> delete('klausurfragen'); 
	}
}
?>